import request from '@/utils/request'
import qs from 'qs'

const prefix = '/v1'

export function employeeList(params) {
    return request.post(`${prefix}/employee/list`, params) 
}

// 员工批量分配部门
export function batchList(params) {
    return request.post(`${prefix}/employee/batchList`, params) 
}

// 员工重置密码
export function restPassword(params) {
    return request.post(`${prefix}/employee/restPassword`, qs.stringify(params, {
        method: 'POST',
        headers: {'content-type': 'application/x-www-form-urlencoded'}
    }));
}

// 登录员工更换头像
export function updateAvatar(params) {
    return request.post(`${prefix}/employee/updateAvatar`, qs.stringify(params, {
        method: 'POST',
        headers: {'content-type': 'application/x-www-form-urlencoded'}
    }));
}

export function employeeAll() {
    return request.get(`${prefix}/employee/all`) 
}


export function saveOrUpdate(params) {
    return request.post(`${prefix}/employee/saveOrUpdate`, params)
}

export function deleteById(id) {
    return request.post(`${prefix}/employee/delete`, qs.stringify({id}, {
        method: 'POST',
        headers: {'content-type': 'application/x-www-form-urlencoded'}
    }));
}

export function selectByDeptId(deptId) {
    return request.post(`${prefix}/employee/selectByDeptId`, qs.stringify({deptId}, {
        method: 'POST',
        headers: {'content-type': 'application/x-www-form-urlencoded'}
    }));
}